# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("//bazel:pl_build_system.bzl", "pl_cc_library", "pl_cc_test", "pl_cc_test_library")

package(default_visibility = ["//src:__subpackages__"])

pl_cc_library(
    name = "cc_library",
    srcs = glob(
        ["*.cc"],
        exclude = [
            "**/*_test.cc",
        ],
    ),
    hdrs = glob(
        ["*.h"],
        exclude = [
            "**/*_mock.h",
            "test_utils.h",
        ],
    ),
    deps = [
        "//src/carnot/planner/distributedpb:distributed_plan_pl_cc_proto",
        "//src/common/event:cc_library",
        "//src/common/system:cc_library",
        "//src/shared/bloomfilter:cc_library",
        "//src/shared/k8s/metadatapb:metadata_pl_cc_proto",
        "//src/shared/metadatapb:metadata_pl_cc_proto",
        "//src/shared/upid:cc_library",
        "@com_github_cameron314_concurrentqueue//:concurrentqueue",
        "@com_github_rlyeh_sole//:sole",
        "@com_google_googletest//:gtest_prod",
    ],
)

pl_cc_test_library(
    name = "test_utils",
    hdrs = ["test_utils.h"],
    deps = [
        ":cc_library",
    ],
)

pl_cc_test(
    name = "state_manager_test",
    srcs = [
        "cgroup_metadata_reader_mock.h",
        "state_manager_test.cc",
    ],
    data = glob(["testdata/**/*"]),
    deps = [
        ":cc_library",
        ":test_utils",
        "//src/common/testing/event:cc_library",
    ],
)

pl_cc_test(
    name = "metadata_filter_test",
    srcs = ["metadata_filter_test.cc"],
    deps = [":cc_library"],
)

pl_cc_test(
    name = "pids_test",
    srcs = ["pids_test.cc"],
    deps = [":cc_library"],
)

pl_cc_test(
    name = "k8s_objects_test",
    srcs = ["k8s_objects_test.cc"],
    deps = [":cc_library"],
)

pl_cc_test(
    name = "cgroup_metadata_reader_test",
    srcs = ["cgroup_metadata_reader_test.cc"],
    data = glob(["testdata/**/*"]),
    deps = [
        ":cc_library",
    ],
)

pl_cc_test(
    name = "cgroup_path_resolver_test",
    srcs = ["cgroup_path_resolver_test.cc"],
    data = glob(["testdata/**/*"]),
    deps = [
        ":cc_library",
    ],
)

pl_cc_test(
    name = "metadata_state_test",
    srcs = ["metadata_state_test.cc"],
    deps = [
        ":cc_library",
        "//src/common/testing/event:cc_library",
    ],
)
